<template>
  <a-modal
    title="远程操作"
    :width="800"
    :visible="visible" 
    @ok="handleSubmit"
    @cancel="handleCancel"
    cancelText="关闭"
    style="top:20px;"
  >
   <iframe 
      :src="this.url.webRtcSrc" 
      id="mytest"  
      :width="750" :height="830"
      :frameBorder="0" >


   </iframe>
  
  </a-modal>
</template>

<script>
    
  import {   postAction  } from '@/api/manage'

  export default {
    name: "RemoteModal",
    mixins:[ ],
    data () {
      return {
        visible: false,  
        queryParam: {},
        model: {}, 
        record:{},
        labelCol: {
          xs: { span: 24 },
          sm: { span: 5 },
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 16 },
        },
       
        url: {
               webRtcSrc:"http://www.163.com",
               getWebRtcUrl:"phone/phoneInstances/getWebRtcUrl",
          },
      }
    },
    created () {
      console.log("createdRemote");
        // setInterval(() => {
        //     console.log("检查进度中。。。");
        //      this.loadData(1);
        //   }, 3000);
    },

    methods: {
      show (record) {
         
        this.visible = true;
        this.record = record; 
        this.$nextTick(() => { 
          
           
            postAction(`${window._CONFIG['domianURL']}/${this.url.getWebRtcUrl}`, record).then((res) => {
              if (res.success) {
                console.log(res.result);
                var url = res.result.url + "regionId=" +  encodeURIComponent(res.result.regionId)
                + "&resolution=" +  encodeURIComponent(res.result.resolution)
                + "&vpcId=" +  encodeURIComponent(res.result.vpcId)
                + "&webRtcToken=" +  encodeURIComponent(res.result.webRtcToken)
                + "&eip=" +  encodeURIComponent(res.result.ipAddr)
                + "&instanceId=" +  encodeURIComponent(res.result.instanceId)
                + "&privateIp=" +  encodeURIComponent(res.result.privateIp) 
   
                this.url.webRtcSrc=url;  

                this.$message.success(res.message)
              } else {
                this.$message.warning(res.message)
              }
            })
        });
      },
      close () {
        this.$emit('close');
        this.visible = false;
        this.disableSubmit = false;
        this.selectedRole = [];
      },
      handleSubmit () { 
       this.close()
      },
      handleCancel () {
        this.close()
      },
 
     
  
  
      
    }
  }
</script>

<style scoped>
  @import '~@assets/less/common.less';

   
</style>
